package com.zx.练习题._2022面试题;

/**
 * (java8) 定义一个 FunctionalInterface，使得可以将 System.out::println 赋值给该 FunctionInterface 类型的变量
 */
public class Demo6 {

    public static void main(String[] args) {
        Object o = new Object();
        run(o, System.out::println);
    }

    private static <T> void run(T t, Fun<T> fun) {
        fun.apply(t);
    }

    @FunctionalInterface
    private interface Fun<T> {

        void apply(T t);
    }
}
